package com.hex.ds.hdrs.period.task.po;

import cn.hutool.core.util.StrUtil;
import lombok.Data;
import lombok.ToString;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;

@Data
@ToString
public class PeriodTaskDef implements Serializable {

    private String pkId;

    private String taskCode;

    private String taskName;

    private String taskDesc;

    private String jobCode;

    private String shellPath;

    private String extParam;

    private String isEndTask;

    private int allowErrCount;

    private String mutexJob;

    private String mutexTask;

    private String isOrder;

    private Integer resNum;

    private Integer priorityLevel;

    private String appCode;

    private String appointAgentCode;

    private String planExecDuration;

    private String overPlanDuration;

    private String errDifferDuration;

    private String crtTs;

    private String upTs;

    private String taskRemark;

    private String dependJob;

    private String dependTask;
    
    private String dependJobName;

    private String dependTaskName;

    //下游任务数
    private int downTaskAllNum;

    //下游任务总资源数
    private int downTaskAllRes;

    public List<String> getDependJobList() {
        if (StrUtil.isNotBlank(dependJob)){
            List<String> list = new ArrayList<>();
            Collections.addAll(list, StrUtil.split(dependJob, ","));
            return list;
        }
        return new ArrayList<>();
    }

    public List<String> getDependTaskList() {
        if (StrUtil.isNotBlank(dependTask)){
            List<String> list = new ArrayList<>();
            Collections.addAll(list, StrUtil.split(dependTask, ","));
            return list;
        }
        return new ArrayList<>();
    }

    public String getTaskCodeAndName(){
        return taskCode + "+" + taskName;
    }
}